<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        div {
            width: 750px;
            margin: 0 auto;
        }

        ul {
            display: flex;
        }

        ul>li {
            width: 70px;
            height: 250px;
            overflow: hidden;
            transition: width .2s linear
        }

        img {
            display: block;
            width: 400px;
            height: 250px;
        }


        ol {
            display: flex;
        }


        ol>li {
            width: 10px;
            height: 10px;
            margin: 10px;
            background-color: aquamarine;
        }

        ol>li:first-child {
            background-color: red;
        }
    </style>

</head>

<body>
    <div>
        <ul>

        </ul>
        <ol>
            <li></li>
            <li></li>
            <li></li>
            <li></li>

        </ol>
    </div>




    <script>
        var ul = document.querySelector("ul");

        var str = "img/0";
        var str1 = "";

        for (let i = 1; i <= 4; i++) {
            var url = str + i + ".jpg"
            str1 += ` <li>
                <img src="${url}" alt="">
            </li>`;

        }
        console.log(str1);4
        ul.innerHTML = str1;
        var lis = document.querySelectorAll("ul>li");
        var ollis = document.querySelectorAll("ol>li");
        lis[0].style.width = "350px";


        for (var i = 0; i < lis.length; i++) {

            // console.log(i);//0-4
            lis[i].aaa = i;



            lis[i].onclick = function () {
                // console.log(i);  //6

                for (var k = 0; k < lis.length; k++) {
                    lis[k].style.width = "70px";
                    ollis[k].style.backgroundColor = "aquamarine";
                }
                console.log(this.aaa);

                ollis[this.aaa].style.backgroundColor = "red";

                this.style.width = "350px";
            }
        }
        console.log(i);

    </script>
</body>

</html>